//
//  UserModel.m
//  糗百——王桂敏
//
//  Created by 王桂敏 on 15/5/26.
//  Copyright (c) 2015年 lanouhn. All rights reserved.
//

#import "UserModel.h"

@implementation UserModel

- (id)initWithDictionary:(NSDictionary *)dictionary{
    self = [super init];
    if (self) {
        if (dictionary.allKeys.count > 0) {
            self.age = dictionary[@"age"];
            self.astrology = dictionary[@"astrology"];
            self.big_cover = dictionary[@"big_cover"];
            self.gender = dictionary[@"gender"];
            if (!dictionary[@"id"]) {
                self.uid = dictionary[@"uid"];
            } else {
                self.uid = dictionary[@"id"];
            }

            self.hometown = dictionary[@"hometown"];
            self.job = dictionary[@"job"];
            //#warning qb_age没有算好
            self.qb_age = dictionary[@"qb_age"];
            self.mobile_brand = dictionary[@"mobile_brand"];
    
            self.login = dictionary[@"login"];
            
            self.icon = dictionary[@"icon"];
            self.haunt = dictionary[@"haunt"];

        }

        self.user_url = [NSString stringWithFormat:@"http://nearby.qiushibaike.com/user/%@/detail?AdID=1432516254311507B38D95",self.uid];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:self.age forKey:@"age"];
    [aCoder encodeObject:self.icon forKey:@"icon"];
    [aCoder encodeObject:self.gender forKey:@"gender"];
    [aCoder encodeObject:self.login forKey:@"login"];
    [aCoder encodeObject:self.hometown forKey:@"hometown"];
    [aCoder encodeObject:self.big_cover forKey:@"big_cover"];
    [aCoder encodeObject:self.qb_age forKey:@"qb_age"];
    [aCoder encodeObject:self.job forKey:@"job"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.astrology forKey:@"astrology"];
    [aCoder encodeObject:self.mobile_brand forKey:@"mobile_brand"];
    [aCoder encodeObject:self.haunt forKey:@"haunt"];
}
- (id)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super init]) {
        self.age = [aDecoder decodeObjectForKey:@"age"];
        self.icon = [aDecoder decodeObjectForKey:@"icon"];
        self.gender = [aDecoder decodeObjectForKey:@"gender"];
        self.login = [aDecoder decodeObjectForKey:@"login"];
        self.hometown = [aDecoder decodeObjectForKey:@"hometown"];
        self.big_cover = [aDecoder decodeObjectForKey:@"big_cover"];
        self.qb_age = [aDecoder decodeObjectForKey:@"qb_age"];
        self.job = [aDecoder decodeObjectForKey:@"job"];
        self.uid = [aDecoder decodeObjectForKey:@"uid"];
        self.astrology = [aDecoder decodeObjectForKey:@"astrology"];
        self.mobile_brand = [aDecoder decodeObjectForKey:@"mobile_brand"];
        self.haunt = [aDecoder decodeObjectForKey:@"haunt"];
    }
    return self;
}

- (void)dealloc{
    [_age release];
    [_icon release];
    [_gender release];
    [_login release];
    [_hometown release];
    [_big_cover release];
    [_qb_age release];
    [_job release];
    [_uid release];
    [_haunt release];
    [_astrology release];
    [_mobile_brand release];
    [super dealloc];
}
@end
